/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package thienphuc.patient.dao.impl;

import java.util.Date;
import java.util.List;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import thienphuc.patient.dao.AbstractHibernateDaoSupport;
import thienphuc.patient.dao.DonThuocDAO;
import thienphuc.patient.dto.BenhAn;
import thienphuc.patient.dto.DonThuoc;

/**
 *
 * @author QuocDat
 */
public class DonThuocDAOImpl extends AbstractHibernateDaoSupport<DonThuoc, Integer> implements DonThuocDAO {

    public DonThuocDAOImpl(Class<DonThuoc> classPersistent) {
        super(classPersistent);
    }

    public List<DonThuoc> findByBenhAn(BenhAn benhAn) throws Exception {
        return this.findByProperty(DON_THUOC_BENH_AN, benhAn);
    }

    public List<DonThuoc> findByTrangThaiThanhToan(boolean trangThaiThanhToan) throws Exception {
        return this.findByProperty(DON_THUOC_TRANG_THAI_THANH_TOAN, trangThaiThanhToan);
    }

    public List<DonThuoc> findByNgayKeDon(Date ngayKeDonStart, Date ngayKeDonEnd) throws Exception {
        Criterion criterionNgayKeDon = Restrictions.between(DON_THUOC_NGAY_KE_DON, ngayKeDonStart, ngayKeDonEnd);
        return this.findByCriteria(criterionNgayKeDon);
    }
}